MarkLogic 9 Product Documentation
PUT /v1/config/resources/{name}

Summary

Create or update a resource service extension.

URL Parameters
provider? The name of the provider of the service. Optional, used only as metadata.
version? The version of the service. Optional, used only as metadata.
title? The title of the service. Optional, used only as metadata.
description? A description of the service. Optional, used only as metadata.
method* The name of an HTTP method supported by the extension. Accepted values: get, put, post delete. The parameter may be specified multiple times to specify multiple methods. Optional, used only as metadata.
method:{name}* The name, type, and cardinality of a method parameter. For example, get:the-uri=string. The method must be one of get, put, post, or delete. The {name} is the parameter name. The parameter value is an XQuery SequenceType, including cardinality (*, ?, etc.) such as appears in the type declaration of an XQuery function parameter. Optional, used only as metadata.
Request Headers
Content-type The type of the request body. Since request body must contain XQuery or JavaScript that implements the services provided for the named resource, the content type must be application/xquery or application/vnd.marklogic-javascript.

Required Privileges

This operation requires the rest-admin role, or the following privileges:

http://marklogic.com/xdmp/privileges/rest-admin

http://marklogic.com/xdmp/privileges/rest-writer

http://marklogic.com/xdmp/privileges/rest-reader

Usage Notes

For details on implementing a resource service extension, see Extending the REST API in the REST Application Developer's Guide.

Example

# Note: Use --data-binary instead of -d with curl to preserve newlines
# in the input, such as line-oriented comments (//).

$ curl --anyauth --user user:password -X PUT -i \
  -H "Content-type: application/vnd.marklogic-javascript" \
  --data-binary @"./example.sjs" \
  'http://localhost:8004/v1/config/resources/example'

==> A JavaScript resource addressable through /v1/resources/example. 
    MarkLogic Server returns the following headers:

Server: MarkLogic
Content-Type: text/xml; charset=UTF-8
Content-Length: 211
Connection: close

HTTP/1.1 204 Created
Server: MarkLogic
Content-Type: text/plain; charset=UTF-8
Content-Length: 4
Connection: close
  

Example

$ curl --anyauth --user user:password -X PUT -i \
  -H "Content-type: application/xquery" -d@"./example.xqy" \
  'http://localhost:8004/v1/config/resources/example'

==> An XQuery resource addressable through /v1/resources/example. 
    MarkLogic Server returns the following headers:

Server: MarkLogic
Content-Type: text/xml; charset=UTF-8
Content-Length: 211
Connection: close

HTTP/1.1 204 Created
Server: MarkLogic
Content-Type: text/plain; charset=UTF-8
Content-Length: 4
Connection: close
  

Example

$ curl --anyauth --user user:password -X PUT -i \
  -H "Content-type: application/xquery" -d@"./example.xqy" \
  'http://localhost:8004/v1/config/resources/example?method=get&get:the-uri=string&provider=Acme Widgets'

==> An XQuery resource addressable through /v1/resources/example. The metadata
    for the extension will include parameter name and type information for 
    the GET method. MarkLogic Server returns the following headers:

Server: MarkLogic
Content-Type: text/xml; charset=UTF-8
Content-Length: 211
Connection: close

HTTP/1.1 204 Created
Server: MarkLogic
Content-Type: text/plain; charset=UTF-8
Content-Length: 4
Connection: close
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy